package ch02.Shangji;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.IOException;
import java.util.List;

public class Shangji1 {
    public static void main(String[] args) throws DocumentException {
        SAXReader reader = new SAXReader();
        Document document = reader.read(new File("src/ch02/收藏信息.xml"));

        org.dom4j.Element element = document.getRootElement();

        List brand = element.elements("Brand");
        for (int i = 0; i < brand.size(); i++) {
            org.dom4j.Element element1 = (org.dom4j.Element) brand.get(i);
            String name = element1.attribute("name").getValue();
            List type = element1.elements("Type");
            for (int i1 = 0; i1 < type.size(); i1++) {
                org.dom4j.Element element2 = (Element) type.get(i1);
                String name1 = element2.attribute("name").getValue();
                System.out.println(name+name1);
            }
        }
    }
}
